home *** CD-ROM | disk | FTP | other *** search
/ Champak 147 / (Vol 147) Jan 21 2012.iso / Interface / it.dig / scripts / __Packages / mx / controls / List.as < prev    next >
Text File  |  2012-01-21  |  6KB  |  183 lines

  1. class mx.controls.List extends mx.controls.listclasses.ScrollSelectList
  2. {
  3.    static var symbolOwner = mx.controls.List;
  4.    static var symbolName = "List";
  5.    var className = "List";
  6.    static var version = "2.0.2.127";
  7.    var clipParameters = {rowHeight:1,enabled:1,visible:1,labels:1};
  8.    var scrollDepth = 1;
  9.    var __vScrollPolicy = "on";
  10.    var autoHScrollAble = false;
  11.    function List()
  12.    {
  13.       super();
  14.    }
  15.    function setEnabled(v)
  16.    {
  17.       super.setEnabled(v);
  18.       this.border_mc.backgroundColorName = !v ? "backgroundDisabledColor" : "backgroundColor";
  19.       this.border_mc.invalidate();
  20.    }
  21.    function get labels()
  22.    {
  23.       return this.__labels;
  24.    }
  25.    function set labels(lbls)
  26.    {
  27.       this.__labels = lbls;
  28.       this.setDataProvider(lbls);
  29.    }
  30.    function setVPosition(pos)
  31.    {
  32.       pos = Math.min(this.__dataProvider.length - this.__get__rowCount() + this.roundUp,pos);
  33.       pos = Math.max(0,pos);
  34.       super.setVPosition(pos);
  35.    }
  36.    function setHPosition(pos)
  37.    {
  38.       pos = Math.max(Math.min(this.__maxHPosition,pos),0);
  39.       super.setHPosition(pos);
  40.       this.hScroll(pos);
  41.    }
  42.    function setMaxHPosition(pos)
  43.    {
  44.       this.__maxHPosition = pos;
  45.       this.invScrollProps = true;
  46.       this.invalidate();
  47.    }
  48.    function setHScrollPolicy(policy)
  49.    {
  50.       if(policy.toLowerCase() == "auto" && !this.autoHScrollAble)
  51.       {
  52.          return undefined;
  53.       }
  54.       super.setHScrollPolicy(policy);
  55.       if(policy == "off")
  56.       {
  57.          this.setHPosition(0);
  58.          this.setVPosition(Math.min(this.__dataProvider.length - this.__get__rowCount() + this.roundUp,this.__vPosition));
  59.       }
  60.    }
  61.    function setRowCount(rC)
  62.    {
  63.       if(isNaN(rC))
  64.       {
  65.          return undefined;
  66.       }
  67.       var _loc2_ = this.getViewMetrics();
  68.       this.setSize(this.__width,this.__rowHeight * rC + _loc2_.top + _loc2_.bottom);
  69.    }
  70.    function layoutContent(x, y, tW, tH, dW, dH)
  71.    {
  72.       this.totalWidth = tW;
  73.       this.totalHeight = tH;
  74.       this.displayWidth = dW;
  75.       var _loc4_ = !(this.__hScrollPolicy == "on" || this.__hScrollPolicy == "auto") ? dW : Math.max(tW,dW);
  76.       super.layoutContent(x,y,_loc4_,dH);
  77.    }
  78.    function modelChanged(eventObj)
  79.    {
  80.       super.modelChanged(eventObj);
  81.       var _loc3_ = eventObj.eventName;
  82.       if(_loc3_ == "addItems" || _loc3_ == "removeItems" || _loc3_ == "updateAll" || _loc3_ == "filterModel")
  83.       {
  84.          this.invScrollProps = true;
  85.          this.invalidate("invScrollProps");
  86.       }
  87.    }
  88.    function onScroll(eventObj)
  89.    {
  90.       var _loc3_ = eventObj.target;
  91.       if(_loc3_ == this.vScroller)
  92.       {
  93.          this.setVPosition(_loc3_.scrollPosition);
  94.       }
  95.       else
  96.       {
  97.          this.hScroll(_loc3_.scrollPosition);
  98.       }
  99.       super.onScroll(eventObj);
  100.    }
  101.    function hScroll(pos)
  102.    {
  103.       this.__hPosition = pos;
  104.       this.listContent._x = - pos;
  105.    }
  106.    function init(Void)
  107.    {
  108.       super.init();
  109.       if(this.__get__labels().length > 0)
  110.       {
  111.          var _loc6_ = new Array();
  112.          var _loc3_ = 0;
  113.          while(_loc3_ < this.__get__labels().length)
  114.          {
  115.             _loc6_.addItem({label:this.__get__labels()[_loc3_],data:this.data[_loc3_]});
  116.             _loc3_ = _loc3_ + 1;
  117.          }
  118.          this.setDataProvider(_loc6_);
  119.       }
  120.       this.__maxHPosition = 0;
  121.    }
  122.    function createChildren(Void)
  123.    {
  124.       super.createChildren();
  125.       this.listContent.setMask(MovieClip(this.mask_mc));
  126.       this.border_mc.move(0,0);
  127.       this.border_mc.setSize(this.__width,this.__height);
  128.    }
  129.    function getRowCount(Void)
  130.    {
  131.       var _loc2_ = this.getViewMetrics();
  132.       return this.__rowCount != 0 ? this.__rowCount : Math.ceil((this.__height - _loc2_.top - _loc2_.bottom) / this.__rowHeight);
  133.    }
  134.    function size(Void)
  135.    {
  136.       super.size();
  137.       this.configureScrolling();
  138.       var _loc3_ = this.getViewMetrics();
  139.       this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  140.    }
  141.    function draw(Void)
  142.    {
  143.       if(this.invRowHeight)
  144.       {
  145.          this.invScrollProps = true;
  146.          super.draw();
  147.          this.listContent.setMask(MovieClip(this.mask_mc));
  148.          this.invLayoutContent = true;
  149.       }
  150.       if(this.invScrollProps)
  151.       {
  152.          this.configureScrolling();
  153.          delete this.invScrollProps;
  154.       }
  155.       if(this.invLayoutContent)
  156.       {
  157.          var _loc3_ = this.getViewMetrics();
  158.          this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  159.       }
  160.       super.draw();
  161.    }
  162.    function configureScrolling(Void)
  163.    {
  164.       var _loc2_ = this.__dataProvider.length;
  165.       if(this.__vPosition > Math.max(0,_loc2_ - this.getRowCount() + this.roundUp))
  166.       {
  167.          this.setVPosition(Math.max(0,Math.min(_loc2_ - this.getRowCount() + this.roundUp,this.__vPosition)));
  168.       }
  169.       var _loc3_ = this.getViewMetrics();
  170.       var _loc4_ = this.__hScrollPolicy == "off" ? this.__width - _loc3_.left - _loc3_.right : this.__maxHPosition + this.__width - _loc3_.left - _loc3_.right;
  171.       if(_loc2_ == undefined)
  172.       {
  173.          _loc2_ = 0;
  174.       }
  175.       this.setScrollProperties(_loc4_,1,_loc2_,this.__rowHeight);
  176.       if(this.oldVWidth != _loc4_)
  177.       {
  178.          this.invLayoutContent = true;
  179.       }
  180.       this.oldVWidth = _loc4_;
  181.    }
  182. }
  183.